﻿using Autofac;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyWeb.ServiceBus.Extensions.AutofacM
{
    public static class AopSwitchRegister
    {
        /// <summary>
        /// 根据AOP开关，注入AOP
        /// </summary>
        /// <param name="builder"></param>
        public static void AddAopSwitchRegister(this ContainerBuilder builder)
        {
            #region 根据AOP开关，注入AOP

            //// AOP 开关，如果想要打开指定的功能，只需要在 appsettigns.json 对应对应 true 就行。
            //var cacheType = new List<Type>();
            ////系统Redis缓存切面
            //if (AppSettings.app(new string[] { "AppSettings", "RedisCachingAOP", "Enabled" }).ObjToBool())
            //{
            //    builder.RegisterType<RedisCacheAOP>();
            //    cacheType.Add(typeof(RedisCacheAOP));
            //}
            ////系统Cache缓存切面
            //if (AppSettings.app(new string[] { "AppSettings", "MemoryCachingAOP", "Enabled" }).ObjToBool())
            //{
            //    builder.RegisterType<CacheAOP>();
            //    cacheType.Add(typeof(CacheAOP));
            //}
            ////系统方法事务切面
            //if (AppSettings.app(new string[] { "AppSettings", "TranAOP", "Enabled" }).ObjToBool())
            //{
            //    builder.RegisterType<TranAOP>();
            //    cacheType.Add(typeof(TranAOP));
            //}
            ////系统方法日志切面
            //if (AppSettings.app(new string[] { "AppSettings", "LogAOP", "Enabled" }).ObjToBool())
            //{
            //    builder.RegisterType<LogAOP>();
            //    cacheType.Add(typeof(LogAOP));
            //}
            #endregion
        }
    }
}
